#include "XDirServiceHandle.h"
#include "protobuf/xmsg_com.pb.h"
#include "XMsg.h"
#include "XTools.h"
using namespace xmsg;
XDirServiceHandle::XDirServiceHandle()
{
}

XDirServiceHandle::~XDirServiceHandle()
{
}

void XDirServiceHandle::DirReq(xmsg::XMsgHead *head,const XMsg *message)
{
    xmsg::XDirReq req;
    req.ParseFromArray(message->data,message->size);
    XCOM_LOG_DEBUG("XDirServiceHandle::DirReq path="<<req.path());
    xmsg::XDirRes res;
    res.set_res(XDirRes_XDirResType_DRT_OK);
    xmsg::XDirRes_XDir*dir=res.add_dirs();
    dir->set_filegroup("hxiaoyun");
    dir->set_fileuser("hxiaoyun");
    dir->set_filetime("2019-09-09");
    dir->set_filetype("txt");
    dir->set_filesize(100);
    dir->set_filelink(1);
    dir->set_filename("123");
    xmsg::XMsgHead resHead;
    resHead.set_msg_type(xmsg::MSG_DIR_RES);
    resHead.set_msg_size(res.ByteSizeLong());
    resHead.set_service_name(head->service_name());
    resHead.set_msg_id(head->msg_id());
    if(!SendMsg(&resHead,&res)){
        XCOM_LOG_ERROR("XDirServiceHandle::DirReq SendMsg error");
    }
}
